Fizz-Buzz¶
Write a python program which iterates the integers from 1 to 50.
For multiples of three print “fizz” instead of the number.
For the multiples of five print “buzz”.
For numbers which are multiples of both three and five print “fizzbuzz”.
Expected output:
fizzbuzz
1
2
fizz
4
buzz
for i in range(50):
if i % 3 == 0 and i % 5 == 0:
print("fizzbuzz")
continue
elif i % 3 == 0:
print("fizz")
continue
elif i % 5 == 0:
print("buzz")
continue
print(fizzbuzz)
Output:
fizzbuzz
1
2
fizz
4
buzz
fizz
7
8
fizz
buzz
11
. . .
fizzbuzz
46
47
fizz
49